using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Presentation.Contracts;
using Presentation;
using Globals;

namespace ProjektZespolowy
{
    public partial class CreateAccount : Page, ICreateAccountView
    {
        #region Members

        /// <summary>
        /// Instance of presenter.
        /// </summary>
        private CreateAccountPresenter presenter;

        #endregion Members

        #region Override Methods

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            presenter = new CreateAccountPresenter(this);
        }

        #endregion Override Methods

        #region Private Methods

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //only not logged users can add account
            if (Session[ContentNamesGlobals.SessionWithUserId] != null)
            {
                Response.Redirect("~/Default.aspx");
            }

            if (!IsPostBack)
            {
                presenter.Initialize();
            }
        }

        /// <summary>
        /// Handles the Click event of the btnAddAccount control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnAddAccount_Click(object sender, EventArgs e)
        {
            presenter.AddUser();
        }

        #endregion Private Methods       

        #region ICreateAccountView Members

        /// <summary>
        /// Gets or sets the name of the first.
        /// </summary>
        /// <value>The name of the first.</value>
        public string FirstName
        {
            get
            {
                return txtFirstName.Text;
            }
            set
            {
                txtFirstName.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the name of the last.
        /// </summary>
        /// <value>The name of the last.</value>
        public string LastName
        {
            get
            {
                return txtLastName.Text;
            }
            set
            {
                txtLastName.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the email.
        /// </summary>
        /// <value>The email.</value>
        public string Email
        {
            get
            {
                return txtEmail.Text;
            }
            set
            {
                txtEmail.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the gg.
        /// </summary>
        /// <value>The gg.</value>
        public string Gg
        {
            get
            {
                return txtGg.Text;
            }
            set
            {
                txtGg.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the skype.
        /// </summary>
        /// <value>The skype.</value>
        public string Skype
        {
            get
            {
                return txtSkype.Text;
            }
            set
            {
                txtSkype.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the login.
        /// </summary>
        /// <value>The login.</value>
        public string Login
        {
            get
            {
                return txtLogin.Text;
            }
            set
            {
                txtLogin.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>The password.</value>
        public string Password
        {
            get
            {
                return txtPassword.Text;
            }
            set
            {
                txtPassword.Text = value;
            }
        }

        /// <summary>
        /// Displays the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void DisplayMessage(string message)
        {
            lblMessage.Text = message;
        }

        #endregion ICreateAccountView Members
    }
}
